package cn.wizzer.app.user.modules.models;

import cn.wizzer.app.user.modules.models.enums.TransferStatusEnum;
import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;

import java.io.Serializable;
import java.math.BigDecimal;

@Data
@Table("User_transfer")
@TableIndexes({@Index(name = "unique_no", fields = {"no"}, unique = true),
        @Index(name = "INDEX_CT_AT", fields = {"ctAt"}, unique = false)})
public class UserTransfer extends BaseModel implements Serializable {

    @Column
    @Name
    @Comment("ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    @PrevInsert(uu32 = true)
    private String id;

    @Column("no")
    @Comment("编号")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String no;

    @Column("transfer_user_id")
    @Comment("转账用户id")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String transferUserId;

    @Column("collect_user_id")
    @Comment("收款用户id")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String collectUserId;

    @Column
    @Comment("转账金额")
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 6)
    private BigDecimal amount;

    @Column
    @Comment("状态->-RETURNED:已退回、TRANSFERRING:划转中、RECEIVED:已确认")
    @ColDefine(type = ColType.VARCHAR, width = 16)
    private TransferStatusEnum status;

    @Column("remark")
    @Comment("备注")
    @ColDefine(type = ColType.VARCHAR, width = 128)
    private String remark;

    @Column
    @Comment("创建时间")
    @PrevInsert(els = @EL("$me.now()"))
    private Long ctAt;

    @Column
    @Comment("统计状态")
    @ColDefine(type = ColType.BOOLEAN, width = 32)
    @Default("0")
    private Boolean counted;

}
